﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Test.BLL;

namespace Test.UI
{
    public partial class AddStuInfo : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            UnobtrusiveValidationMode = UnobtrusiveValidationMode.None;
            if (!IsPostBack)
            {
                //绑定下拉列表
                var info = ClassInfoBLL.Select();
                DropDownList1.DataSource = info;
                DropDownList1.DataTextField = "Name";
                DropDownList1.DataValueField = "Id";
                DropDownList1.DataBind();
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Model.StuInfo stuInfo = new Model.StuInfo()
            {
                Comment = TextBox1.Text,
                Name = text2.Value,
                Sex = RadioButton1.Checked ? "男" : "女",
                cid =Convert.ToInt32( DropDownList1.SelectedValue)
            };
            if (StuInfoBLL.Add(stuInfo) > 0)
            {
                Response.Write("<script>alert('添加成功！');location='StuInfoUI.aspx';</script>");
            }
        }

    }
}